1. Field of the invention
The present invention relates to a method and an apparatus for processing data on a computer, and particularly to a program translation method and apparatus therefor, and to a preprocessor method and apparatus for programs written in an object-oriented programing language.
2. Description of the prior art
Conventional computer-based data processing is executed by reading data from a file and then writing the resulting data to another file. More particularly, translation programs such as done in preprocessor and compiler are often run on computers through the step of reading the source program, i.e., the source data, from a source file, and writing the object file, i.e., the result data, to plural result files. A specific example of this data processing method is described below with reference to the figures.
FIG. 7 is a flow chart showing the operation of a preprocessing system of an object-oriented programming language based on the programming language C in a conventional preprocessing-type processing method. For a thorough discussion of object-oriented languages, see, for example, An introduction to object oriented programming, Sakai Hironori, Horiuchi Hitoshi, published by Ohm-sha (in Japanese).
This preprocessing system translates the class definition written in an object-oriented language to a C source program, and then processes this C source program using a C compiler to produce an object (machine language program).
When this preprocessor system is started by specifying the class name, the class definition is read from the file `class.sub.-- name.k` (ST701).
If a superclass is specified in this class definition, the superclass structure definition is read from the file `superclass.sub.-- name.h` (ST702). Here, the term superclass is used to indicate a class which is in a higher position. For example, in FIG. 5, class A is a superclass to class B or C, because it is necessary to use data in class A, i.e. A.h 504, to make data, i.e., B.h or C.h, in class B or C. The file `superclass.sub.-- name.h` must previously be generated by preprocessing the superclass. In the example shown in FIG. 5, the file `A.h` must first be generated by preprocessing the class A.
This class is written to the file `class.sub.-- name.h` of which the structure definition is written in C source (ST703). At the same time, the procedure definitions written in C source are written to the file `class.sub.-- name.c` for this class (ST704).
With this conventional method, however, the results are always written to the file even when there is no difference between the results previously written to the file and the current results to be written to the file, and the file is therefore always updated. As a result, the file modification date and time are updated to the current (latest) date and time.
Problems arise, however, when software (e.g., the `make` command in the UNIX operating system) controlling a sequence of operations on plural files dependent upon the file modification date/time and individual file dependencies is used to control the overall data process flow. This problem specifically is that even when there is no difference between the current and previous results, files dependent on the updated file are also processed, files dependent on those files are also updated, and this process continues until all files have been processed. For more information on the UNIX `make` command, see UNIX programming environment, B. W. Kernighan, et al., Bell Laboratories, published by Prenticehall, Inc. Englewood Cliffs N.J. 07632. The "make" execution is disclosed in detail in "SunOS Reference Manual (Sun Release 4.1)" released Sep. 15, 1989 by sun microsystems.
This problem is further described using the preprocessor system in the processing system of the above preprocess method.
In programming with object-oriented languages, software being developed is programmed by programming plural classes. The class definitions (source programs) are stored to separate files, each of which is translated by the preprocessor system and compilers into objects (machine language programs), which are then edited by a linker generate a single executable program. Many files are associated with this process. In the UNIX environment, the `make` command is used to sequentially run the preprocessor system, compiler, and other software components.
The overall process applying this conventional preprocessor system to the development of a specific class structure program is described below.
FIG. 4 shows the class hierarchy of the program being developed. Using the inheritance faculty of object-oriented languages, classes B 402 and C 403 are defined as subclasses of class A 401. The arrow 404 indicates that class C 403 references class B 402. In general, the overall process of an object-oriented language program is defined by the different classes referencing each other.
FIG. 5 shows the relationships between the various files generated from the original class definitions through the process obtaining the final object file, i.e., the executable program. The result data stored to the destination file (the file pointed to by each arrow) is generated based on the source data stored in the root file (or files) of each arrow. This indicates that, conversely, each destination file is also dependent on the root file(s), and FIG. 5 therefore also shows the dependency relationship of the various files.
The text 601 shown in FIG. 6 is a text file showing the same dependency relationship shown in FIG. 5. This file is referenced by the UNIX `make` command; the colon (:) in each line indicates that the file preceding the colon is dependent upon the file(s) following the colon.
The process of generating the files as shown in FIGS. 5 and 6 is described further below.
The preprocessor first generates the structure definition file A.h 504 and procedure definition file A.c 505 using the class A class definition file A.k 501.
Then, for class B, using the class B class definition file B.k 502 and the structure definition file A.h 504, class B structure definition file B.h 506 is generated. Also, using the class B definition file B.k 502 procedure definition file B.c 507 is generated. In a similar manner, for class C, class C structure definition file C.h 508 and class C procedure definition file C.c 509 are generated.
As apparent from the above, class A preprocessing must be completed before preprocessing classes B and C.
The class A procedure definition file A.c 505 is then compiled by a C compiler to generate the class A abject file A.o 510. Note that the class A structure definition file A.h 504 is also read during compilation as an included file. A similar procedure is executed to compile the class B procedure definition file B.c 507 and generate the class B object file B.o 511; the class B structure definition file B.h 506 is similarly read as an included file during compilation. The class C procedure definition file C.c 509 is then compiled to generate the class C objecz file C.o 512. At this time, however, both the class C structure definition file C.h 508 and the referenced class B structure definition file B.h 506 are read as included files.
The resulting object files A.o 510, B.o 511, and C.o 512 are then joined by the linker to generate the final executable file program 513.
If the class A, B, and C class definitions are thus defined and the `make` command is executed, the preprocessor system, compiler, and linker will be sequentially run based on the file dependency defined in text 601 (FIG. 6) to produce all of the above files.
The updated files and the process executed are described below when only the procedures in the class definition of class A are modified and the `make` command is re-executed to generate the various files. It should be noted before the following description that file generation in the initial `make` command call is no problem because all files must necessarily be generated the first time the `make` command is run.
It is assumed that the class A class definition file A.k 501 has been so modified as to make a change in the class A procedure definition file A.c 505, but no change in the class A structure definition file A.h 504. First, the preprocessor is run to process the modified class definition file A.k 501 so as to update the structure and procedure definition files A.h 504 and A.c 505. In this case, there will be no actual change in the structure definition file A.h 504. Even though the class structure is not modified in the class definition file A.h 504, the preprocessor system will also update both files A.h 504 and A.c 505 based on steps ST703 and ST704 in the FIG. 7 flow chart. Since there is no substantial change in the structure definition file A.h 504 in step ST703, the processing in step ST703 would be a waist of time.
Furthermore, the preprocessor system further carries out unnecessaryupdating steps: such as updating the two files B.h 506 and C.h 508, and for accomplishing the updating of the two files B.h 506 and C.h 508, the class definition files B.k 502 and C.k 503 are processed. Also, files B.h 506, B.c 507, C.h 508, and C.c 509 are unnecessarily updated.
In other words, even with such a minor modification as explained in the above assumption, the preprocessor system is run sequentially three times (A.k.fwdarw.A.h and A.c; B.k.fwdarw.B.h and B.c; and C.k.fwdarw.C.h and c.c) according to this file dependency relationship, and the three class object files A.o 510, B.o 511, and C.O 512 are all updated. The linker is then run to update the program 513. As a result, a total of seven processes (A.k.fwdarw.A.h and A.c; B.k.fwdarw.B.h and S.c; C.k.fwdarw.C.h and C.c; A.h and A.c.fwdarw.A.o; B.h and B.c.fwdarw.B.o; C.h and C.c.fwdarw.C.o; and A.o, B.o and C.o.fwdarw.Program) in the preprocessing, compiling, and linking sequence are required to update the program 513.
As is obvious from the above description, the structure definition file A.h 504 is updated in this method even though there is no change in the class A structure definition. This causes the files dependent on this file to also be processed, thus increasing the overall processing time.